home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 October / Ahoy_Magazine_85-10_1985_Double_L.d64 / radioactive dec. (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  1KB  |  51 lines

  1. 0 print"[147]":poke53280,0:poke53281,6:poke646,1
  2. 1 rem
  3. 2 rem  * radioactive decay *
  4. 3 rem    rupert report #22
  5. 4 rem
  6. 5 rem monte carlo simulation of a
  7. 6 rem two-product decay chain
  8. 7 rem
  9. 10 ttl=100   :rem initial number
  10. 20 sf=22/ttl :rem plot scale factor
  11. 30 nd=2  :rem number of daughters
  12. 40 dim nuc(ttl)
  13. 100 rem  decay constants
  14. 110 dc(0)=.2
  15. 120 dc(1)=.05 :rem first daughter
  16. 130 dc(2)=0   :rem stable isotope
  17. 140 m(0)=ttl  :rem initial amount
  18. 150 print chr$(147)"  =-= radioactive decay =-="
  19. 160 for t=1 to 20
  20. 170 gosub 400 :rem <<< gosub 500 to plot
  21. 180 for n=1 to ttl
  22. 190 if rnd(0) > dc(nuc(n)) then 220
  23. 200 k=nuc(n) : nuc(n)=k+1
  24. 210 m(k)=m(k)-1 : m(k+1)=m(k+1)+1
  25. 220 next n
  26. 230 next t
  27. 240 poke 214,23 : print
  28. 250 poke 211,12
  29. 260 print"=press a key to continue==>";
  30. 270 get a$ : if a$="" then 270
  31. 280 goto 150
  32. 390 end
  33. 395 rem --- print value routine ---
  34. 400 print tm ">>",
  35. 410 for j=0 to nd
  36. 420 print m(j),:next j
  37. 430 tm=tm+1
  38. 440 return
  39. 495 rem
  40. 499 rem ---- plot routine ----
  41. 500 for j=0 to nd
  42. 510 y=m(j) : s$=right$(str$(j),1)
  43. 520 row%=22-sf*y : col%=2*t-2
  44. 530 if row%>23 then row%=23
  45. 540 if row%<=0 then row%=0
  46. 550 if col%>38 then col%=38
  47. 560 if col%<0 then col%=0
  48. 570 poke 214,row%: print
  49. 580 poke 211,col%: print s$
  50. 590 next j : return
  51.